#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_pushButton_clicked()
{
    const int radius = ui->lineEdit->text().toInt();
    const double area = calcArea(radius);
    ui->label_3->setText(QString().setNum(area));
}

void Dialog::on_lineEdit_textChanged(const QString &arg1)
{
    const int radius = ui->lineEdit->text().toInt();
    const double area = calcArea(radius);
    ui->label_3->setText(QString().setNum(area));
}

double Dialog::calcArea(int radius)
{
    const static double PI = 3.14;
    return (PI * radius * radius);
}
